<?php
class Location_Model_Category extends Zend_Db_Table_Abstract
{
	protected $_name = 'location_category';
	
	public function insert(array $data)
	{
		//TODO : code to clean data before insert here
		parent::insert($data);
	}
	
	public function update(array $data, $where)
	{
		//TODO : code to clean data before update here
		parent::update($data, $where);
	}
	
	public function fetchById($id)
	{
		$row = $this->find((int)$id)->toArray();		
		return $row;
	}

	public function fetchParentCategories()
	{
		return $this->_db->fetchAll("SELECT * FROM location_category WHERE parent = 0 AND isvisible =1 ORDER BY ordre");
	}
	
	public function deleteById($id)
	{
		return $this->delete('id = '.(int)$id);
	}
}
